/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
/**
 *
 * $Id: RechargerData.hpp,v 1.3 2009-05-13 07:18:17 amaula Exp $
 * 
 * \file
 * \brief Protocol encoder/decoder header for the Recharger protocol.
 * \author Mikko Elomaa <mikko.elomaa@tkk.fi>
 * \author Antti Maula <antti.maula@tkk.fi>
 */
#ifndef _MACI_RECHARGERDATA_HPP_
#define _MACI_RECHARGERDATA_HPP_
#include "RechargerTypes.hpp"
#include "MaCIData.hpp"
#include "common/timestamp.hpp"
#include <vector>
#include <map>

namespace gim {
  namespace binbag{class CBinBag;}
}

namespace MaCI {
  namespace Recharger {

    /** Recharger protocol parser.
     *
     * This class contains the methods for decoding/encoding a 
     * Recharger message.
     */
    class CRechargerData : public CMaCIData
    {
    public:
      CRechargerData();
      ~CRechargerData();

      // Copy constructor.
      CRechargerData(const CRechargerData &);

      // Assignment operator.
      CRechargerData &operator=(const CRechargerData &);

      // Interface for moving data around
      bool DecodeFrom(gim::binbag::CBinBag *aBinBag);
      void Reset();
      void Print(const int level) const;


      /** Set timestamp element.
       * 
       */
      bool SetTimestamp(const Common::TTimestamp &aStamp);


      /** Set command element.
       * This function stores a element of type TCommand.
       *
       * @return                'true' if element was succesfully added,
       *                        'false' if element already exists.
       */
      bool SetCommand(const TCommand &aCmd);


      /** Set channel element.
       * This function stores a element of type TChannel.
       *
       * @return                'true' if element was succesfully added,
       *                        'false' if element already exists.
       */
      bool SetChannel(const TChannel &aChannel);

      
      /** Set status element.
       *
       * This function stores a element of type TStatus.
       *       
       * @return                'true' if element was succesfully added,
       *                        'false' if element already exists.
       */
      bool SetStatus(const TStatus &aStatus);


      /** Set RechargerCurrent element.
       *
       * This function stores a element of type TCurrent.
       *       
       * @return                'true' if element was succesfully added,
       *                        'false' if element already exists.
       */
      bool SetCurrent(const TCurrent &aCurrent);


      /** Set RechargerVoltage element.
       *
       * This function stores a element of type TVoltage.
       *       
       * @return                'true' if element was succesfully added,
       *                        'false' if element already exists.
       */
      bool SetVoltage(const TVoltage &aVoltage);


      /** Set RechargerCharge element.
       *
       * This function stores a element of type TCharge.
       *       
       * @return                'true' if element was succesfully added,
       *                        'false' if element already exists.
       */
      bool SetCharge(const TCharge &aCharge);


      /** Set RechargerEvent element.
       *
       * This function stores a element of type TRechargerEvent.
       *
       *
       * @return                'true' if element was succesfully added,
       *                        'false' if element already exists.
       */
      bool SetRechargerEvent(const TRechargerEvent &aEvent);


      /** Get pointer to TTimestamp element.
       * 
       * @return                 Pointer to element if such exists, 
       *                         NULL if element doesn't exists in the
       *                         container.
       */
      const MaCI::Common::TTimestamp *GetTimestamp(void) const;
      

      /** Get pointer to TCommand element.
       *
       * @return                 Pointer to element if such exists, 
       *                         NULL if element doesn't exists in the
       *                         container.
       */
      const TCommand *GetCommand(void) const;


      /** Get pointer to TChannel element.
       *
       * @return                 Pointer to element if such exists, 
       *                         NULL if element doesn't exists in the
       *                         container.
       */
      const TChannel *GetChannel(void) const;


      /** Get pointer to TStatus element.
       *
       * @return                 Pointer to element if such exists, 
       *                         NULL if element doesn't exists in the
       *                         container.
       */
      const TStatus *GetStatus(void) const;

      
      /** Get pointer to TCurrent element.
       *
       * @return                 Pointer to element if such exists, 
       *                         NULL if element doesn't exists in the
       *                         container.
       */
      const TCurrent *GetCurrent(void) const;


      /** Get pointer to TVoltage element.
       *
       * @return                 Pointer to element if such exists, 
       *                         NULL if element doesn't exists in the
       *                         container.
       */
      const TVoltage *GetVoltage(void) const;
      

      /** Get pointer to TCharge element.
       *
       * @return                 Pointer to element if such exists, 
       *                         NULL if element doesn't exists in the
       *                         container.
       */
      const TCharge *GetCharge(void) const;


     /** Get pointer to TRechargerEvent element.
       *
       * @return                 Pointer to element if such exists, 
       *                         NULL if element doesn't exists in the
       *                         container.
       */
      const TRechargerEvent *GetRechargerEvent(void) const;

    private:
      const Common::TTimestamp *iTimestampPtr; ///< Pointer to timestamp if exists
      const TCommand *iCommandPtr; ///< Pointer to command if any.
      const TChannel *iChannelPtr; ///< Pointer to channel.
      const TStatus *iStatusPtr; ///< Pointer to status.
      const TCurrent *iCurrentPtr; ///< Pointer to current.
      const TVoltage *iVoltagePtr; ///< Pointer to voltage.
      const TCharge *iChargePtr; ///< Pointer to charge.
      const TRechargerEvent *iRechargerEventPtr;  ///< Pointer to event
    };
    
  }
}

#endif
